package org.demo.honor.representation.controller;

import org.demo.honor.pojo.exceptions.MobileTypeNotFoundException;
import org.demo.honor.pojo.exceptions.OrderNotFoundException;
import org.demo.honor.pojo.response.ErrorResponse;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class ExceptionHandlers {

    @ExceptionHandler(MobileTypeNotFoundException.class)
    public ResponseEntity<ErrorResponse> handleMobileTypeNotFoundException(MobileTypeNotFoundException e) {
        return ResponseEntity.status(HttpStatus.NOT_FOUND)
                .body(new ErrorResponse(MobileTypeNotFoundException.code, e.getMessage()));
    }

    @ExceptionHandler(OrderNotFoundException.class)
    public ResponseEntity<ErrorResponse> handleOrderNotFoundException(OrderNotFoundException e) {
        return ResponseEntity.status(HttpStatus.NOT_FOUND)
                .body(new ErrorResponse(OrderNotFoundException.code, e.getMessage()));
    }
}
